#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int Is_leap_year(int year)
{
    if(year % 4 == 0 && year % 100 != 0 || year % 400 ==0)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
int main()
{
    int year = 0;
    int month = 0;
    int day = 0;
    int i = 0;
    int num = 0;
    int daynum = 0;
    scanf("%d %d %d",&year,&month,&day);
    num = Is_leap_year(year); 
    for(i=1;i<month;i++)
    {
        if(num == 1 && i == 2)
        {
            daynum += 29;
        }
        if(num == 0 && i == 2)
        {
            daynum += 28;
        }
        if(i == 1 || i == 3 || i == 5 ||
           i == 7 || i == 8 || i == 10 ||
           i == 12)
        {
            daynum += 31;
        }
        if(i == 4 || i == 6 ||i == 9 || i == 11)
        {
            daynum += 30;
        } 
    }
    printf("%d\n",daynum + day);
    return 0;
}